package com.unsiv.helicopterdemo;

import android.app.Activity;
import android.os.Bundle;

/**
 * 
 * @author fanzhen
 * @time 11:25:01 AM Oct 18, 2011
 * @email fanzhen.meng@gmail.com
 */
public class AudioTest extends Activity {
	private final float increment_50 = (float) (2 * Math.PI) * 50 / 44100;
	private final float increment_100 = (float) (2 * Math.PI) * 100 / 44100;
	private final float increment_1000 = (float) (2 * Math.PI) * 1000 / 44100;
	private final float increment_2000 = (float) (2 * Math.PI) * 2000 / 44100;
	private final float samples[] = new float[1204];
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		new Thread(new Runnable() {
			public void run() {
				float angle = 0;
				MyAudioHelper device = new MyAudioHelper();
				while (true) {
					for (int i = 0; i < samples.length; i++) {
						samples[i] = (float) Math.sin(angle);
						angle += increment_50;
					}
					device.writeSamples(samples);
				}
			}
		}).start();
	}
}